package com.xjgzinfo.usdp.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.Instant;

/**
 * 图片资源
 */
@Entity
@Table(name = "img_assets")
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class ImgAssets implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GenericGenerator(name = "snowFlakeIdGenerator", strategy = "com.xjgzinfo.usdp.domain.util.SnowFlakeIdGenerator")
    @GeneratedValue(generator = "snowFlakeIdGenerator", strategy = GenerationType.SEQUENCE)
    @JsonFormat(shape = JsonFormat.Shape.NUMBER)
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 图片名称
     */
    @NotNull
    @Size(max = 50)
    @Column(name = "name", length = 50, nullable = false)
    private String name;

    /**
     * 类别
     */
    @NotNull
    @Size(max = 50)
    @Column(name = "type", length = 50, nullable = false)
    private String type;

    /**
     * 地址
     */

    @Lob
    @Column(name = "url", nullable = false)
    private String url;

    /**
     * 上传用户
     */
    @Size(max = 50)
    @Column(name = "create_user", length = 50)
    private String createUser;

    /**
     * 上传时间
     */
    @Column(name = "create_date")
    private Instant createDate;

    /**
     * 是否公开
     */
    @Column(name = "is_public")
    private Boolean isPublic;

    /**
     * 用户ID
     */
    @Column(name = "user_id")
    private Long userId;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted")
    private Integer isDeleted;

    // jhipster-needle-entity-add-field - JHipster will add fields here
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ImgAssets name(String name) {
        this.name = name;
        return this;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public ImgAssets type(String type) {
        this.type = type;
        return this;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public ImgAssets url(String url) {
        this.url = url;
        return this;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public ImgAssets createUser(String createUser) {
        this.createUser = createUser;
        return this;
    }

    public Instant getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Instant createDate) {
        this.createDate = createDate;
    }

    public ImgAssets createDate(Instant createDate) {
        this.createDate = createDate;
        return this;
    }

    public Boolean isIsPublic() {
        return isPublic;
    }

    public ImgAssets isPublic(Boolean isPublic) {
        this.isPublic = isPublic;
        return this;
    }

    public void setIsPublic(Boolean isPublic) {
        this.isPublic = isPublic;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public ImgAssets userId(Long userId) {
        this.userId = userId;
        return this;
    }

    public Integer getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Integer isDeleted) {
        this.isDeleted = isDeleted;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof ImgAssets)) {
            return false;
        }
        return id != null && id.equals(((ImgAssets) o).id);
    }

    @Override
    public int hashCode() {
        return 31;
    }

    @Override
    public String toString() {
        return "ImgAssets{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", type='" + type + '\'' +
                ", url='" + url + '\'' +
                ", createUser='" + createUser + '\'' +
                ", createDate=" + createDate +
                ", isPublic=" + isPublic +
                ", userId=" + userId +
                ", isDeleted=" + isDeleted +
                '}';
    }
}
